package com.lax.advertserver.service;

import com.lax.advertserver.bean.sys.RoleInfo;
import com.lax.advertserver.dao.sys.RoleInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

import java.util.concurrent.TimeUnit;

@Service
public class TestServiceImpl {

    @Autowired
    private RoleInfoMapper roleInfoMapper;

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    public RoleInfo getRoleList(RoleInfo roleInfo){
        RoleInfo roleInfo1 = roleInfoMapper.selectByPrimaryKey(roleInfo.getId());
        stringRedisTemplate.opsForValue().set(roleInfo1.getId(),roleInfo1.getRoleName(),60*2, TimeUnit.SECONDS);
        String a = stringRedisTemplate.opsForValue().get(roleInfo1.getId());
        System.out.println(a);
        stringRedisTemplate.delete(roleInfo1.getId());
        String a1 = stringRedisTemplate.opsForValue().get(roleInfo1.getId());
        System.out.println(a1);
        return roleInfo1;
    }

}
